/*
 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FOUNDATION_EVENT_CESFWK_INNERKITS_INCLUDE_COMMON_EVENT_STUB_H
#define FOUNDATION_EVENT_CESFWK_INNERKITS_INCLUDE_COMMON_EVENT_STUB_H

#include "icommon_event.h"
#include "iremote_stub.h"
#include "nocopyable.h"

namespace OHOS {
namespace EventFwk {
class CommonEventStub : public IRemoteStub<ICommonEvent> {
public:
    CommonEventStub();

    virtual ~CommonEventStub() override;

    /**
     * Processes the remote Request.
     *
     * @param code Indicates the code to send.
     * @param data Indicates the message to send.
     * @param reply Indicates the message to reply.
     * @param option Indicates the message option.
     * @return Returns ERR_NONE if success, otherwise ERR_CODE.
     */
    virtual int OnRemoteRequest(
        uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;

    /**
     * Publishes a common event.
     *
     * @param event Indicates the common event data.
     * @param publishInfo Indicates the publish info.
     * @param commonEventListener Indicates the last subscriber to receive the event.
     * @param userId Indicates the user ID.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool PublishCommonEvent(const CommonEventData &event, const CommonEventPublishInfo &publishinfo,
        const sptr<IRemoteObject> &commonEventListener, const int32_t &userId) override;

    /**
     * Publishes a common event.
     *
     * @param event Indicates the common event data.
     * @param publishInfo Indicates the publish info.
     * @param commonEventListener Indicates the last subscriber to receive the event.
     * @param uid Indicates the uid.
     * @param userId Indicates the user ID.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool PublishCommonEvent(const CommonEventData &event, const CommonEventPublishInfo &publishinfo,
        const sptr<IRemoteObject> &commonEventListener, const uid_t &uid, const int32_t &userId) override;

    /**
     * Subscribes to common events.
     *
     * @param subscribeInfo Indicates the subscribe information.
     * @param commonEventListener Indicates the subscriber object.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool SubscribeCommonEvent(
        const CommonEventSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &commonEventListener) override;

    /**
     * Unsubscribes from common events.
     *
     * @param commonEventListener Indicates the subscriber object.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool UnsubscribeCommonEvent(const sptr<IRemoteObject> &commonEventListener) override;

    /**
     * Gets the current sticky common event.
     *
     * @param event Indicates the common event.
     * @param eventData Indicates the common event data.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool GetStickyCommonEvent(const std::string &event, CommonEventData &eventData) override;

    /**
     * Dumps the state for common event service.
     *
     * @param event Indicates the specified event.
     * @param userId Indicates the user id.
     * @param state Indicates the output result.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool DumpState(const std::string &event, const int32_t &userId, std::vector<std::string> &state) override;

    /**
     * Freezes the specified process.
     *
     * @param uid Indicates the uid of frozen process.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool Freeze(const uid_t &uid) override;

    /**
     * Unfreezes the specified process.
     *
     * @param uid Indicates the uid of unfrozen process.
     * @return Returns true if successful; false otherwise.
     */
    virtual bool Unfreeze(const uid_t &uid) override;

private:
    DISALLOW_COPY_AND_MOVE(CommonEventStub);
};
}  // namespace EventFwk
}  // namespace OHOS

#endif  // FOUNDATION_EVENT_CESFWK_INNERKITS_INCLUDE_COMMON_EVENT_STUB_H
